package game;

import java.util.*;
public class GridCage {

	public static final int CAGE_UDEF = -1;
	public static final int CAGE_1 = 0;
	final String oprts[] = { "+", "-", "*", "/", "=" };
	// O = Origin (0,0) - must be the upper leftmost cell
	// X = Other cells used in cage
	public static final int[][][] CAGE_COORDS = new int[][][] {
			// O typeID 0
			{ { 0, 0 } },
			// O
			// X typeID 1
			{ { 0, 0 }, { 0, 1 } },
			// OX typeID 2
			{ { 0, 0 }, { 1, 0 } },
			// O
			// X
			// X typeID 3
			{ { 0, 0 }, { 0, 1, }, { 0, 2 } },
			// OXX typeID 4
			{ { 0, 0 }, { 1, 0 }, { 2, 0 } },
			// O
			// XX typeID 5
			{ { 0, 0 }, { 0, 1 }, { 1, 1 } },
			//  O
			// XX typeID 6
			{ { 0, 0 }, { 0, 1 }, { -1, 1 } },
			// OX
			// X typeID 7
			{ { 0, 0 }, { 1, 0 }, { 1, 1 } },
			// OX
			// X typeID 8
			{ { 0, 0 }, { 1, 0 }, { 0, 1 } },
			/*
			// OX
			// XX
			{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } },
			// OX
			// X
			// X
			{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 0, 2 } },
			// OX
			// X
			// X
			{ { 0, 0 }, { 1, 0 }, { 1, 1 }, { 1, 2 } },
			// O
			// X
			// XX
			{ { 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 2 } },
			// O
			// X
			// XX
			{ { 0, 0 }, { 0, 1 }, { 0, 2 }, { -1, 2 } } 
			*/
			};

	// List of cage's cells
	public ArrayList<GridCell> mCells;
	// Type of the cage
	// public int mType;
	// Id of the cage
	public int mId;
	// Operation result of the cage
	public int mResult;
	// Operator of the cage
	// value:0 -- '+';1 -- '-';2 -- '*';3 -- '/';4 -- '=';
	public int mOperator;
	// String in UI
	public String mText;

	public GridCage(int Id,int result,int operator) {
		this.mId = Id;
		this.mResult =result;
		this.mOperator = operator;
		this.mCells = new ArrayList<GridCell>();
		this.mText = " "+this.mResult+" "+oprts[this.mOperator];

	}
	
	public void addCell(GridCell cell){
		this.mCells.add(cell);
	}

	public void setmId(int mId) {
		this.mId = mId;
		for (GridCell cell : this.mCells)
			cell.mCageId = this.mId;

	}

	@Override
	public String toString() {
		return "GridCage [mCells=" + mCells + ", mId=" + mId + ", mResult="
				+ mResult + ", mOperator=" + mOperator + "]";
	}
	

}
